package com.example.sys.pay.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.core.po.BaseAuthPo;
import com.example.core.utils.DateTimeUtils;
import com.example.sys.job.po.ISysJob;
import com.example.sys.log.po.ISysLog;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@Setter
@Getter
@ApiModel(value = "订单信息")
@TableName(value = "sys_pay")
public class SysPay extends BaseAuthPo<SysPay> implements ISysLog, ISysJob {

    @ApiModelProperty(value = "支付方式")
    @TableField(value = "type")
    private String type;

    @ApiModelProperty(value = "附言")
    @TableField(value = "attach")
    private String attach;

    @ApiModelProperty(value = "金额")
    @TableField(value = "fee")
    private Double fee;

    @ApiModelProperty(value = "支付状态")
    @TableField(value = "payed")
    private boolean payed;

    @ApiModelProperty(value = "业务名称")
    @TableField(value = "model_name")
    private String modelName;

    @ApiModelProperty(value = "业务id")
    @TableField(value = "model_id")
    private String modelId;

    @ApiModelProperty(value = "二维码")
    @TableField(value = "url")
    private String url;

    @ApiModelProperty(value = "支付编号")
    @TableField(value = "pay_code")
    private String payCode;

    @ApiModelProperty(value = "截止时间")
    @TableField(value = "end_time")
    public Date endTime;

    @Override
    public Date getRunTime() {
        return this.endTime;
    }

    @Override
    public void recalculateFields() {
        super.recalculateFields();
        if (endTime == null) {
            endTime = DateTimeUtils.getTimeAddMinute(1);
        }
    }
}
